package model;

import java.util.List;

import model.impl.Station;
import DAO.ScheduleDAO;
import DTO.PassengerDTO;
import DTO.ScheduleDTO;

/**
 * This is an interface that provides a complete business transactions with 
 * an entity of Schedule
 */
public interface Schedule  {
	
	/**
	 * This method checks if there is a schedule in DB which has the same 
	 * DTO implementation as given DTO. If it is found in DB, method 
	 * removes it.
	 * 
	 * @param scheduleDTO - DTO of schedule which is required to be removed
	
	 */
	public void removeUniqueSchedule(ScheduleDTO scheduleDTO);
	
	/**
	 * This method checks if there is a schedule in DB which has the same 
	 * DTO implementation as the given DTO. If it is NOT found in DB, method 
	 * creates a new Schedule entity from DTO and saves it.
	 * 
	 * @param scheduleDTO - DTO of schedule which is required to be saved
	 */
	public void saveUniqueSchedule(ScheduleDTO scheduleDTO);
	
	/**
	 * Checks given station and looks for all schedules that has this station 
	 * as arrival one.
	 * 
	 * @param  station - Station entity for which to look for Schedule
	 * @return         - List of Schedules which has the given station as an
	 * 					 instance variable or null if nothing was found
	 */
	public List<ScheduleDTO> getStationArrivalSchedule(Station station);	
	
	/**
	 * Checks given station and looks for all schedules that has this station as
	 * departure one.
	 * 
	 * @param  station - Station entity for which to look for Schedule
	 * @return         - List of Schedules which has the given station as an 
	 * 					 instance variable or null if nothing was found
	 */
	public List<ScheduleDTO> getStationDeparturelSchedule(Station station);
	
	/**
	 * Checks given DTO and fined the schedule that has the same DTO. If it's 
	 * found it looks for all passengers that has tickets for this schedule.
	 * 
	 * @param  scheduleDTO - DTO of schedule for which is required to find all 
	 * 						 passengers
	 * @return         	   - List of Passengers which has a ticket for this schedule 
	 *						 or null in any other cases.
	 */
	public List<PassengerDTO> getAllPassengersOnSchedule(ScheduleDTO scheduleDTO);

	/**
	 * Method looks for all the Schedule entities in DB.
	 * 
	 * @return	- List of all Schedule entities in DB or null if there is no
	 * 			  schedules in DB.
	 */
	public List<model.impl.Schedule> findAll();

	/**
	 * Looks for all schedules that satisfy the given in scheduleDTO parameters.
	 * It is as is a wrapper with transaction for method findRequiredTrains in 
	 * {@link ScheduleDAO}.
	 * 
	 * @param scheduleDTO  - DTO of schedule for which is required to find trains.
	 * @return			   - List of ScheduleDTO which satisfy given parameters
	 * 					     or null if such Schedules was not found
	 */
	public List<ScheduleDTO> findRequiredTrains(ScheduleDTO scheduleDTO);
}
